﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Projet_WPF.Model
{
    class Patient
    {
        #region variables
        private string _name;
        private string _firstname;
        private DateTime _birthday;
        private int _id;
        private List<Model.Observation> _observations;
        #endregion


        #region getter / setter
        /// <summary>
        /// liste des observatiosn pour un patient
        /// </summary>
        public List<Observation> Observations
        {
            get { return _observations; }
            set { _observations = value; }
        }

        /// <summary>
        /// id du patient
        /// </summary>
        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }

        /// <summary>
        /// Date de naissance
        /// </summary>
        public DateTime Birthday
        {
            get { return _birthday; }
            set { _birthday = value; }
        }

        /// <summary>
        /// prénom
        /// </summary>
        public string Firstname
        {
            get { return _firstname; }
            set { _firstname = value; }
        }

        /// <summary>
        /// nom
        /// </summary>
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        #endregion

        public static Patient CreatePatient(string name, string firstname, DateTime birthday, int id, List<Model.Observation> observations)
        {
            Patient patient = new Patient();
            patient.Name = name;
            patient.Firstname = firstname;
            patient.Birthday = birthday;
            patient.Id = id;
            patient.Observations = observations;
            return patient;
        }

        public static Patient CreatePatient(string name, string firstname, DateTime birthday)
        {
            Patient patient = new Patient();
            patient.Name = name;
            patient.Firstname = firstname;
            patient.Birthday = birthday;
            patient.Id = 0;

            DataAccess.Patient access = new DataAccess.Patient();

            foreach (var item in access.GetListPatient())
            {
                if (item.Id > patient.Id)
                    patient.Id = item.Id;
            }

            patient.Id = patient.Id + 1;
            patient.Observations = new List<Observation>();
            
            return patient;
        }

        public Patient()
        {
            _name = "";
            _firstname = "";
            _birthday = new DateTime();
            _id = 0;
            _observations = null;
        }
    }
}
